unit codemyth.form.login.cfg;

interface

uses
  Classes, SysUtils, IniFiles, Forms, Windows;

const
  csIniloginSection = 'login';

  {Section: login}
  csIniloginremember_pwd = 'remember_pwd';
  csIniloginlast_user = 'last_user';
  csIniloginlast_pwd = 'last_pwd';

type
  TIniLogin = class(TObject)
  private
    {Section: login}
    Floginremember_pwd: Boolean;
    Floginlast_user: string;
    Floginlast_pwd: string;
  public
    procedure LoadSettings(Ini: TIniFile);
    procedure SaveSettings(Ini: TIniFile);

    {Section: login}
    property loginremember_pwd: Boolean read Floginremember_pwd write Floginremember_pwd;
    property loginlast_user: string read Floginlast_user write Floginlast_user;
    property loginlast_pwd: string read Floginlast_pwd write Floginlast_pwd;
  end;

var
  IniLogin: TIniLogin = nil;

implementation

procedure TIniLogin.LoadSettings(Ini: TIniFile);
begin
  if Ini <> nil then
  begin
    {Section: login}
    Floginremember_pwd := Ini.ReadBool(csIniloginSection, csIniloginremember_pwd, True);
    Floginlast_user := Ini.ReadString(csIniloginSection, csIniloginlast_user, 'jd');
    Floginlast_pwd := Ini.ReadString(csIniloginSection, csIniloginlast_pwd, 'adf');
  end;
end;

procedure TIniLogin.SaveSettings(Ini: TIniFile);
begin
  if Ini <> nil then
  begin
    {Section: login}
    Ini.WriteBool(csIniloginSection, csIniloginremember_pwd, Floginremember_pwd);
    Ini.WriteString(csIniloginSection, csIniloginlast_user, Floginlast_user);
    Ini.WriteString(csIniloginSection, csIniloginlast_pwd, Floginlast_pwd);
  end;
end;

initialization
  IniLogin := TIniLogin.Create;

finalization
  IniLogin.Free;

end.

